package nc.tb.report;


import java.awt.print.PageFormat;

import nc.tb.cube.cell.ICellType;
import nc.tb.pub.NtbFormula;

import org.w3c.dom.Element;
import org.w3c.dom.Text;
import com.ufsoft.report.sysplugin.xml.AbsXmlParser;
import com.ufsoft.table.AreaPosition;
import com.ufsoft.table.print.PrintSet;

public class XMLParser2CellProp extends AbsXmlParser {

	private static final String CELLTYPE="celltype";
	private static final String CELL_DIMDEF="dimdef";
	private static final String DIMVECTOR="dimv";
	private static final String VARID="varid";
	private static final String AXIS_FORMULA="axisformula";

	
	protected void objectToXmlImpl(Element element, Object obj) {
		CellWrap cellprop = (CellWrap) obj;
		addToElement("type",""+cellprop.getCellType(),element);
		NtbFormula formula=cellprop.getAxisFormula();
		if(formula!=null){
			addToElement(AXIS_FORMULA, formula, element);
		}
		
		if(cellprop.getCellDimDef()!=null)addToElement("celldimdef", cellprop.getCellDimDef().getPrimaryKey(), element);
		if(cellprop.getDimVector()!=null)addToElement("dimvector", cellprop.getDimVector().getDimMembersIdx(), element);
		if(cellprop.getVarId()!=null)addToElement("varid", cellprop.getVarId(), element);
		
	}


	protected Object xmlToObjectImpl(Element element) {
		CellWrap cellprop = new CellWrap(ICellType.DATACELL);
		int celltype = Integer.parseInt(getFromElementStr("type",element));
		cellprop.setCellType(celltype);
//		String axisFormula=getFromElementStr("axf",element);
//		cellprop.setAxisFormula(axisFormula);
		
		return cellprop;
	}
	
	public String getSupportClassName() {
		return CellWrap.class.getName();
	}

}
